import { request } from 'ice';

export interface QueryParams {
  /** 订单号 */
  orderNo?: string;
  /** 物流编号 */
  shippingLabel?: string;
  /** 卖家编号 */
  sellerNo?: string;
  // 防伪标识
  securityCode?: string;
  /** 时间 开始 */
  startTime?: number;
  /** 时间 截止 */
  endTime?: number;
  filterTime?: number[];
}

/** 待鉴定列表 */
export const stayAppraisalList = (pageParams: ICommon.PageParams, formData: QueryParams): Promise<any> => {
  const params = {
    ...pageParams,
    ...formData,
    startTime: (formData?.filterTime || [])[0]?.valueOf(),
    endTime: (formData?.filterTime || [])[1]?.valueOf(),
    filterTime: undefined,
  };
  return request.get('/operating/appraisal/stay/page', { params }).then((res) => ({
    total: res?.total || 0,
    list: res?.data || [],
  }));
};

/** 已鉴定列表 */
export const alreadyAppraisalList = (pageParams: ICommon.PageParams, formData: QueryParams): Promise<any> => {
  const params = {
    ...pageParams,
    ...formData,
    startTime: (formData?.filterTime || [])[0]?.valueOf(),
    endTime: (formData?.filterTime || [])[1]?.valueOf(),
    filterTime: undefined,
  };
  return request.get('/operating/appraisal/already/page', { params }).then((res) => ({
    total: res?.total || 0,
    list: res?.data || [],
  }));
};
